﻿
CREATE PROCEDURE [dbo].[P_OBTERLISTA_T07_QUARTO]
	@cd_quarto [int]
   ,@cd_predio [int]
   ,@ds_identificacao [varchar](50)
   ,@sr_serial_tv [varchar](50)
   
AS
BEGIN
	SELECT
	T.cd_quarto
    ,T.cd_predio
    ,T.ds_identificacao
    ,T.sr_serial_tv
    ,tp.ds_identificacao ds_identificacao_predio
  FROM T07_QUARTO T
  inner join T08_PREDIO tp on T.cd_predio = tp.cd_predio
  WHERE
    (t.cd_quarto = @cd_quarto OR @cd_quarto IS NULL)
    AND (t.cd_predio = @cd_predio OR @cd_predio IS NULL)
    AND (t.ds_identificacao like '%' + @ds_identificacao + '%' OR @ds_identificacao IS NULL)
    AND (t.sr_serial_tv = @sr_serial_tv OR @sr_serial_tv IS NULL)
    
END